package com.ky.untils;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;

//import java.util.HashSet;
//方法一
public  class SensitiveWordsUtil {


    public static String filter(String concent) throws IOException {
        ArrayList<String> arrayList = new ArrayList<> ();

       Reader fileReader = new FileReader ("src\\main\\resources\\word.txt");
        BufferedReader bufferedReader = new BufferedReader (fileReader);
        String  line;
        while ((line  = bufferedReader.readLine ())!=null){
            arrayList.add (line);

        }
        bufferedReader.close ();

        for (String s : arrayList) {
            if (concent.contains (s)) {
                concent =  concent.replaceAll (s,"*");
            }
        }

        return concent;
    }
}
